import { EntitySchema } from '@mikro-orm/core';

export class TypechoShop {
  id!: number;
  title?: string;
  imgurl?: string;
  text?: string;
  price?: number = 0;
  num?: number = 0;
  type?: number = 1;
  value?: string;
  cid?: number = -1;
  uid?: number = 0;
  vipDiscount!: string;
  created?: number = 0;
  status?: number = 0;
  sellNum?: number = 0;
  isMd?: number = 1;
  sort?: number = 0;
  subtype?: number = 0;
  isView?: number = 1;
}

export const TypechoShopSchema = new EntitySchema({
  class: TypechoShop,
  properties: {
    id: { primary: true, type: 'number' },
    title: { type: 'string', length: 300, nullable: true },
    imgurl: { type: 'string', length: 500, nullable: true },
    text: { type: 'string', columnType: 'text', nullable: true },
    price: { type: 'number', nullable: true, default: 0 },
    num: { type: 'number', nullable: true, default: 0 },
    type: { type: 'number', nullable: true, default: 1 },
    value: { type: 'string', columnType: 'text', nullable: true },
    cid: { type: 'number', nullable: true, default: -1 },
    uid: { type: 'number', nullable: true, default: 0 },
    vipDiscount: { type: 'string', fieldName: 'vipDiscount', length: 255, default: '0.1' },
    created: { type: 'number', nullable: true, default: 0 },
    status: { type: 'number', nullable: true, default: 0 },
    sellNum: { type: 'number', fieldName: 'sellNum', nullable: true, default: 0 },
    isMd: { type: 'number', fieldName: 'isMd', nullable: true, default: 1 },
    sort: { type: 'number', nullable: true, default: 0 },
    subtype: { type: 'number', nullable: true, default: 0 },
    isView: { type: 'number', fieldName: 'isView', nullable: true, default: 1 },
  },
});
